/*
 * @Author: 严晗 823841034@qq.com
 * @Date: 2023-10-10 20:35:42
 * @LastEditors: 严晗 823841034@qq.com
 * @LastEditTime: 2023-10-18 19:38:51
 * @FilePath: /yike-admin/Users/yanhan/vite-project/src/api/index.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import axios from '~/axios'

// 登录
export function login(username, password) {
	return axios({
		methods: 'post',
		url: '/auth/oauth/token',
		params: {
			username,
			password,
			grant_type: 'password',
			scope: 'server',
			tenantId: 'yike_oa',
		},
		headers: {
			isToken: false,
			Authorization: 'Basic eWlrZV9vYTp5aWtlX29h',
		},
	})
}

// 退出登录
export function logout() {
	return axios.delete('/auth/token/logout')
}

// 获取用户信息
export function getUserInfo() {
	return axios.get('/admin/user/info', { params: { tenantId: 'yike_oa' } })
}

// 获取侧边菜单信息
export function getMenus() {
	return axios.get('/admin/menu', { params: { parentId: '-1', tenantId: 'yike_oa' } })
}

// 修改密码
export function updatePassword(data) {
	return axios.put('/admin/user/edit', data)
}
